import type { RouteRecordRaw } from "vue-router"
/**
 * 路由meta对象参数说明
 * meta: {
 *      title:          菜单栏及 tagsView 栏、菜单搜索名称（国际化）
 *      hidden：        是否隐藏此路由
 *      icon：          菜单、tagsView 图标，阿里：加 `iconfont xxx`，fontawesome：加 `fa xxx`
 * }
 */

/**
 * 静态路由（默认路由）(常量路由)
 * 页面左边展示的菜单就是通过遍历静态路由表得到的
 */
export const staticRoutes: Array<RouteRecordRaw> = [
  //login
  {
    path: "/login",
    name: "Login",
    component: () => import("@/views/login/index.vue"),
    meta: {
      hidden: true,
    },
  },
  //404
  {
    path: "/404",
    name: "404",
    component: () => import("@/views/error/404.vue"),
    meta: {
      hidden: true,
    },
  },
  //首页
  {
    path: "/",
    component: () => import("@/layout/index.vue"),
    redirect: "/home",
    children: [
      {
        path: "home",
        name: "Home",
        component: () => import("@/views/home/index.vue"),
        meta: {
          title: "首页",
          icon: "ele-HomeFilled",
        },
      },
    ],
  },
]

/**
 * 定义动态路由(异步路由)
 * 专门 用来盛放需要权限控制才能展示的路由菜单
 * 未来用户登录以后,根据用户的权限信息,把用户权限对应的允许的路由信息交给静态路由表
 */
export const allAsyncRoutes: Array<RouteRecordRaw> = [
  //商品管理
  {
    path: "/product",
    name: "Product",
    component: () => import("@/layout/index.vue"),
    meta: {
      title: "商品管理",
      icon: "ele-HomeFilled",
    },
    children: [
      {
        path: "trademark",
        name: "Trademark",
        component: () => import("@/views/product/Trademark/index.vue"),
        meta: {
          title: "品牌管理",
        },
      },
      {
        path: "attr",
        name: "Attr",
        meta: {
          title: "平台属性管理",
        },
        component: () => import("@/views/product/Attr/index.vue"),
      },
      {
        path: "spu",
        name: "Spu",
        meta: {
          title: "SPU",
        },
        component: () => import("@/views/product/Spu/index.vue"),
      },
      {
        path: "sku",
        name: "Sku",
        meta: {
          title: "SKU",
        },
        component: () => import("@/views/product/Sku/index.vue"),
      },
    ],
  },
  //学生管理
  {
    path: "/student",
    name: "Student",
    component: () => import("@/layout/index.vue"),
    meta: {
      title: "学生管理",
      icon: "ele-Avatar",
    },
    children: [
      {
        path: "kaoqin",
        name: "Kaoqin",
        component: () => import("@/views/Student/Kaoqin.vue"),
        meta: {
          title: "考勤管理",
        },
      },
      {
        path: "kaoshi",
        name: "Kaoshi",
        meta: {
          title: "考试管理",
        },
        component: () => import("@/views/Student/Kaoshi.vue"),
      },
    ],
  },
  /* 权限管理路由 start */

  {
    path: "/acl",
    name: "Acl",
    component: () => import("@/layout/index.vue"),
    redirect: "/acl/user/list",
    meta: {
      title: "权限管理",
      icon: "ele-Setting",
    },
    children: [
      {
        name: "User",
        path: "/acl/user/list",
        component: () => import("@/views/acl/user/index.vue"),
        meta: {
          title: "用户管理",
        },
      },
      {
        name: "Role",
        path: "/acl/role/list",
        component: () => import("@/views/acl/role/index.vue"),
        meta: {
          title: "角色管理",
        },
      },
      {
        name: "RoleAuth",
        path: "/acl/role/auth",
        component: () => import("@/views/acl/role/roleAuth.vue"),
        meta: {
          title: "角色管理",
          hidden: true,
          activeMenu: "/acl/role/list",
        },
      },
      {
        name: "Permission",
        path: "/acl/permission/list",
        component: () => import("@/views/acl/permission/index.vue"),
        meta: {
          title: "菜单管理",
        },
      },
    ],
  },
  /* 权限管理路由 end */
]

/**
 * 定义任意路由
 * 这个路由是用户随意输入路径的时候要匹配的，最终重定向到404，这个路由在注册的时候，必须是注册在最后一个
 */
export const anyRoutes: Array<RouteRecordRaw> = [
  /* 匹配任意的路由 必须最后注册 */
  {
    path: "/:pathMatch(.*)",
    name: "Any",
    redirect: "/404",
    meta: {
      hidden: true,
    },
  },
]
